<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BasketItem
 *
 * @author shenlon
 */
class BasketItem {

    /**
     * Product in the basket
     * @var Product
     */
    private $product;

    /**
     * Quantity of the product in the basket
     * @var int
     */
    private $quantity;

    /**
     * Price of the product
     * @var float
     */
    private $itemPrice;

    /**
     * Default constructor, setting quantity to 1 and reading items price
     * @param Product $product 
     */
    public function __construct($product) {
        $this->product = $product;
        $this->quantity = 1;
        $this->itemPrice = $product->price;
    }

    public function __set($key, $value) {
        if (!property_exists($this, $key))
            throw new Exception("Key $key does not exist in class " . __CLASS__);
        $this->$key = $value;
    }

    public function __get($key) {
        if (!property_exists($this, $key))
            throw new Exception("Key $key does not exist in class " . __CLASS__);
        return $this->$key;
    }

}

?>
